/**
 * 权限相关的数据
 * Created by gcc on 2017/9/29.
 */

import Vue from "vue";


// 页码相关
let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};

//页面状态相关
let status = {
  //查看图片
  modalImage: {
    isShow: false,
    url: ''
  },
  modalUserInfo: {
    isShow: false
  },
};

// 和网络交互相关的参数
let params = {
  //搜索条件
  userName: '',
  employeeId:"",
  orderBy: '',
  isRepeated:false,

  showUserInfo: {
    firstName: '',
    lastName: '',
    thirdParty: '',
    state: '',
    country: '',
    phone: '',
    email: '',
    isPushMessage: '',
    isAdEmail: '',
    facebook: '',
    whatsapp: '',
    twitter: '',
    instagram: '',
    source: '',
    inviteCode: '',
    useContent: ''
  },
  selectedUsers:[],
};

// 页面的数据源
let data = {
  userEmployeeList: [],
};

let userEmployeeTable = function (self) {
  return [
    // {
    //   type: 'selection',
    //   align: 'center',
    //   fixed: 'left',
    //   width: 60
    // },
    {
      type: 'index',
      title: '#',
      width: 60,
      key: 'index',
      fixed: 'left',
      align: 'center',
    },
     {
      title: '头像',
      key: 'avatar',
      width:  80,
      align: 'center',
      render: (h, params) => {
        return (
          <div>
            <img src={params.row.userAvatar} height={50} onClick={()=>{
              status.modalImage.url = params.row.userAvatar;
              status.modalImage.isShow = true;
            }}></img>
          </div>
        );
      }
    },
    {
      title: '用户名',
      key: 'userName',
      width: self.$yMobile()?150:220,
      fixed: 'left',
      render: (h, params) => {
        let hideName = Vue.prototype.$tiyHideUsername(params.row.userName);
        if (!self.$authority('USER-1-210')) {
          return (<span>{hideName}</span>);
        } else {
          return (
            <div>
              <a style="padding:6px;font-size:13px" onClick={() => {self.showUserInfo(params.index);}}>
            {hideName}
              </a>
            </div>
          );
        }
      }
    },
    {
      title: '推广员工一',
      key: 'employee1Name',
      width: 120
    },
    {
      title: '推广员工二',
      key: 'employee2Name',
      width: 120
    },
    {
      title: '匹配时间',
      key: 'createtime',
      width: 200,
      align: 'center',
      render: (h, params) => {
        return h('div', self.$tiyBJTime(params.row.createtime));
      }
    }
  ];
};


export default {
  tPage: page,
  tStatus: status,
  tParams: params,
  userEmployeeTable: userEmployeeTable,
  tData: data,
  tRole: {}
};
